package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsStreamShift;
import com.scau402.system.service.IWmsStreamShiftService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 直播排班班次Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/streamShift")
public class WmsStreamShiftController extends BaseController
{
    @Autowired
    private IWmsStreamShiftService wmsStreamShiftService;

    /**
     * 查询直播排班班次列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamShift:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsStreamShift wmsStreamShift)
    {
        startPage();
        List<WmsStreamShift> list = wmsStreamShiftService.selectWmsStreamShiftList(wmsStreamShift);
        return getDataTable(list);
    }

    /**
     * 导出直播排班班次列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamShift:export')")
    @Log(title = "直播排班班次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsStreamShift wmsStreamShift)
    {
        List<WmsStreamShift> list = wmsStreamShiftService.selectWmsStreamShiftList(wmsStreamShift);
        ExcelUtil<WmsStreamShift> util = new ExcelUtil<WmsStreamShift>(WmsStreamShift.class);
        util.exportExcel(response, list, "直播排班班次数据");
    }

    /**
     * 获取直播排班班次详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:streamShift:query')")
    @GetMapping(value = "/{streamShift}")
    public AjaxResult getInfo(@PathVariable("streamShift") String streamShift)
    {
        return success(wmsStreamShiftService.selectWmsStreamShiftByStreamShift(streamShift));
    }

    /**
     * 新增直播排班班次
     */
    @PreAuthorize("@ss.hasPermi('system:streamShift:add')")
    @Log(title = "直播排班班次", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsStreamShift wmsStreamShift)
    {
        wmsStreamShift.setCreateBy(getUsername());
        return toAjax(wmsStreamShiftService.insertWmsStreamShift(wmsStreamShift));
    }

    /**
     * 修改直播排班班次
     */
    @PreAuthorize("@ss.hasPermi('system:streamShift:edit')")
    @Log(title = "直播排班班次", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsStreamShift wmsStreamShift)
    {
        return toAjax(wmsStreamShiftService.updateWmsStreamShift(wmsStreamShift));
    }

    /**
     * 删除直播排班班次
     */
    @PreAuthorize("@ss.hasPermi('system:streamShift:remove')")
    @Log(title = "直播排班班次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{streamShifts}")
    public AjaxResult remove(@PathVariable String[] streamShifts)
    {
        return toAjax(wmsStreamShiftService.deleteWmsStreamShiftByStreamShifts(streamShifts));
    }
}
